﻿<DemoPageSectionComponent Id="Editors-DateRangePicker-HighlightSpecialDates" ShowSizeMode="true">
    <ChildContentWithParameters Context="Params">
        <label for="deHighlightDates" class="demo-text cw-320 mb-1">Date Range</label>
        <DxDateRangePicker @bind-StartDate="@DateTimeStart"
                           @bind-EndDate="@DateTimeEnd"
                           SizeMode="Params.SizeMode"
                           CssClass="cw-320"
                           InputId="deHighlightDates">
            <DayCellTemplate>
                <a class="@GetCssClassNames(context)">@context.Day.ToString()</a>
            </DayCellTemplate>
        </DxDateRangePicker>
    </ChildContentWithParameters>

    @code {
        DateTime DateTimeStart { get; set; } = DateTime.Today;
        DateTime DateTimeEnd { get; set; } = DateTime.Today.AddDays(7);
        CalendarData Data { get; set; } = new CalendarData();

        string GetCssClassNames(DateTime date) {
            if(Data.PersonalDays.Exists(d => DaysEqual(d, date)))
                return "fw-bold text-success";
            if(Data.Holidays.Exists(d => DaysEqual(d, date)))
                return "text-danger";
            if(Data.BirthDates.Exists(d => DaysEqual(d, date)))
                return "fw-bold text-info";

            return string.Empty;
        }

        bool DaysEqual(DateTime date1, DateTime date2) {
            return (date1.Year == date2.Year && date1.DayOfYear == date2.DayOfYear);
        }

    }

</DemoPageSectionComponent>
